<h2><?php echo $this->description ?></h2>

<h3>Actions</h3>
<a href="<?php echo $this->baseURL() ?>/apidesigner/<?php echo $this->moduleName ?>/<?php echo $this->controllerName ?>/<?php echo $this->actionName ?>/edit/">Edit message</a> - <a href="<?php echo $this->baseURL() ?>/apidesigner/<?php echo $this->moduleName ?>/<?php echo $this->controllerName ?>/<?php echo $this->actionName ?>/history/">View message history</a>

<h3>Arguments</h3>

<div id="arguments">
<?php

if(empty($this->inputDefinition)) echo 'No argument for this action';
else {
foreach($this->inputDefinition as $num => $data) echo '<p><b>'.$data['name'].'</b> ('.$data['mandatory'].')<br /><span>'.@$data['description'].'</span></p>';	
}

?>
</div>

<h3>Examples</h3>

<?php
if(empty($this->examples)) echo 'No example defined for this message';
else {
	
	$num = 1;
foreach($this->examples as $number => $data) {
	echo '<h4>example '.$num.'</h4>';
	echo '<p>'.$data['definition'].'</p>';
	echo '<p><b>Input:</b> '.$this->baseURL().'/'.$this->moduleName.'/'.$this->controllerName.'/'.$this->actionName.'/';
	if(!empty($data['inputValues'])) {
		foreach($data['inputValues'] as $key => $value) {
			echo $key.'/'.$value[0].'/';
		}	
	}
	'</p>';
	
	echo '<p><b>Output in JSON: </b> '.$data['outputJSON'].'</p>';
	echo '<p><b>Output in serializedPHP: </b>'.$data['outputSerializedPHP'].'</p>';
	
		
	$num++;
	} //end foreach example
} //end examples empty
?>



<h3>Error codes</h3>

<?php
if(empty($this->errorsList)) echo 'No error for this message';
else {
foreach($this->errorsList as $num => $data) echo '<h4>'.$data['id'].'</b> : '.$data['text'].'</h4>';	
}
?>

<h3>Test API</h3>
<p>Please enter the different values below and click submit to test the API. Message will be signed with your credentials.</p>
<form action="<?php echo $this->baseURL() ?>/apidesigner/index/testapi/actionName/<?php echo $this->actionName ?>/controllerName/<?php echo $this->controllerName ?>/moduleName/<?php echo $this->moduleName ?>/" id="testAPIForm" method="POST">
<?php
if(!empty($this->inputDefinition)) {
	foreach($this->inputDefinition as $num => $data) {
		if($data['type'] == 'set') {
			echo '<p><b>'.$data['name'].'</b> ('.$data['mandatory'].'):';
			//fallback situation we display a text box
			if(empty($data['codeset'])) {
				echo '<input type="text" name="param_'.$data['name'].'" />';
			}
			else {
				$listOptions = preg_split  (  '/,/',  $data['codeset']);

				echo '<select name="param_'.$data['name'].'">';
				echo '<option value=""></option>';
				foreach($listOptions as $num => $value) {
					echo '<option value="'.$value.'">'.$value.'</option>';
				}
				echo '</select>';
			}
			echo '</p>';
		} //end type = set
		else echo '<p><b>'.$data['name'].'</b> ('.$data['mandatory'].'): <input type="text" name="param_'.$data['name'].'" /></p>';
	}
}
?>
<p><b>output</b> (optional): 
	<select name="param_output">
		<option value="serializedphp">serializedphp (default)</option>
		<option value="json">json</option>
		<option value="simplexml">simplexml</option>
	</select>
</p>	

<input type="submit" name="submitButton" value="Test" onclick="YAHOO.draftrack.apidefinition.testapi.testAPICall(this);return false;">
</form>

<h4>Response</h4>
<iframe id="testAPIResponse" src="" ></iframe>







